//
//  TestLayoutConstraintsWC.m
//  sandbox
//
//  Created by 杨岑 on 5/19/15.
//  Copyright (c) 2015 杨岑. All rights reserved.
//

#import "TestLayoutConstraintsWC.h"
#import "NSMutableAttributedString+Ext.h"


@interface TestLayoutConstraintsWC ()
@property (weak) IBOutlet NSButton *button1;
@property (weak) IBOutlet NSButton *button2;
@property (weak) IBOutlet NSLayoutConstraint *vspacingConstraint;
@property (weak) IBOutlet NSLayoutConstraint *button1HeightConstraint;

@end

@implementation TestLayoutConstraintsWC
{
    NSView* _view;
}

- (IBAction)test_cllick:(id)sender {
    NSButton* button = self.button1;
    
    //self.vspacingConstraint.constant += 10;
    //self.button1HeightConstraint.constant += 10;
    NSButtonCell* cell = button.cell;
    
    NSDictionary* attrs = @{NSFontAttributeName: [NSFont labelFontOfSize:13], NSForegroundColorAttributeName: [NSColor blueColor]};
    NSMutableAttributedString* t = [[NSMutableAttributedString alloc] initWithAttributedString:cell.attributedTitle];
    
    NSRange all = NSMakeRange(0, t.length);
    
    [t removeAttribute:NSFontAttributeName range:all];
    [t addAttributes:attrs range:all];
    [t appendAttributedString:[[NSAttributedString alloc] initWithString:@"\nline"]];
    [t appendAttributedString:[NSMutableAttributedString attachmentFromImage:[NSImage imageNamed:NSImageNameColorPanel]]];
    
    cell.attributedTitle = t;
    NSLog(@"%f,%f", cell.cellSize.width, cell.cellSize.height);
    self.button1HeightConstraint.constant = cell.cellSize.height;
}

@end
